The present invention relates to a method of inspecting and/or measuring by picking up the image of an electronic component and processing the image thereof/and more particularly, a line image processing method for inspecting and/or measuring a line image.
In recent years, inspecting and/or measuring methods to which are carried out by the combination of an image pickup apparatus and an image processing apparatus have been popularly used in the field of inspecting and/or measuring industrial products. Of the methods, there have been progress in techniques for inspecting and/or measuring an industrial product by generating a binary image from a gray image thereof, thinning the binary image to form a line image based on the binary image, and then processing the line image. A line image processing method is known as an image-processing algorithm adapted for inspecting and/or measuring industrial products by means of the line image.
In the line image processing method, inspection and/or measurement is carried out by detecting and classifying the configuration of each line of a binary image in which the thickness of the line corresponds to one pixel.
Before the line image processing method is carried out, as shown in FIG. 21, the gray image is binarized to obtain the binary image and then the binary image is thinned to generate the line image. According to the line image processing method, the configuration of each line of the binarized line image is inspected and classified to inspect/measure industrial products.
With reference to FIGS. 22 through 37, a description is made on an example of a conventional line image processing method entitled "IMAGE PROCESSING OF THE PORTRAIT-DRAWING ROBOT (II) (LINE DESCRIPTION)" presented by Hiraishi, Shitanda, and Nakajima at the 1985 National Convention 1256 of Electronic Communication Society.
FIG. 22 is a flowchart showing the conventional line image processing method. In a branch vector-generating process executed at step #11, pixels constituting a line image are addressed as shown in FIG. 26 by using branch vectors shown in FIGS. 24 and 25. Then, the program goes to step #12. The directions of the pixels are shown in FIG. 23. FIGS. 24 and 25 show an example of branch vectors corresponding to the orientations of pixels adjacent to each other.
In a short line-removing process executed at step #12, short lines (shown by 1 of FIG. 27 and by the arrows of FIG. 28) branching from long lines and noise-like short lines (shown by the arrows of FIG. 28) not branching from the long lines are removed. Then, the program goes to step #13. FIG. 28 shows lines of the line image in which the short lines have not been removed from the long lines. FIG. 29 shows lines of the line image in which the short lines have been removed from the long lines.
In a line-connecting process executed at step #13, two lines or more each discontinuous due to the lack of one pixel are connected to each other and then, the program goes to step #14. In this process, the center of each of the patterns to be connected to each other are set at a one pixel-inexistent position as shown in FIG. 30. This connecting method is incapable of connecting lines to each other if they are distant from each other by two pixels or more.
In a branch line-cutting process executed at step #14, a point from which three lines branch and a point from which four lines branch are converted into a point from which one line branches and a point from which two lines branch. Then, the program goes to step #15. FIG. 31 shows a point 2 from which one line branches, a point 3 from which two lines branch, a point 4 from which three lines branch, and a point 5 from which four lines branch. The conversion is made as follows as shown in FIG. 32: Two straight lines each having lengths of L and 2L extend from a branch point and the elevation angle of each branch point is .theta. to make pairs of the straight lines in different directions. The direction of the straight line having the length of L is different from that of the straight line having the length of 2L. An equation 6 shown in FIG. 6 is used to decide the linearity of each pair of the straight lines by examining the linearities of the straight line having the length of L and the straight line having the length of 2L. Straight lines are separated from a branch point except a straight line having the highest degree of linearity. Lines shorter than a predetermined length which are separated from the image are erased. FIG. 33 shows branch points before and after lines are separated from the branch point. FIG. 34 shows a line image before lines are separated from the branch point. FIG. 35 shows a line image after lines are separated from the branch point.
In a line-tracing process executed at step #15, lines of the line image in which branch lines have been cut at step #14 are traced. Lines are traced as shown in FIG. 37 by means of a direction code shown in FIG. 36. The mark .gradient. of FIG. 37 indicates points to be traced. Processing for shaping a line image is executed as described above and lines are classified (hereinafter referred to as clustering).
The conventional construction has, however, a disadvantage in that in the process of generating branch vectors, if there is a large number of branch vectors, it is necessary to perform complicated processing and a large number of processings. In addition, in the line-connecting process of step #13, lines can be connected to each other only when one pixel does not exist between the end points of lines to be connected to each other. That is, lines cannot be connected to each other when two pixels or more do not exist between the end points of the lines to be connected to each other. Further, in the branch line-cutting process executed at step #14, a branch condition is determined locally, not entirely, in the line image. As a result, misjudgments may be made. Due to these disadvantages, in carrying out clustering of each line of a line image to be processed such as a line connected to an unnecessary line to make a long line or a branch line, or discontinuous lines which are the connected to each other, the conventional line image-processing method is incapable of processing the line image with the required accuracy and reliability.